import Router from './index'
import store from '@/store/index'

Router.beforeEach((to, from, next) => {
    // matched：是父路由和子路由组成的数组
    let isLogin = to.matched.some(item => item.meta.isLogin)
    if (isLogin) {
        let token = store.state.login.userInfo.token
        if (token) {
            next()
        } else {
            next('/login')
        }
    } else {
        next()
    }
})